<!--
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
Copyright (c) 2014 Mozilla Corporation

contains two ways to display the same dshield data
non-modal: for http(s)://servername/ipdshield/1.2.3.4
modal: for  Session.set('ipdshieldipaddress','1,2.3.4') then
            $('#modaldshieldwindow').modal()
-->

<template name="ipdshield">
<body>


<div class="container">
    <div class="well">
        dshield: {{dshield.status}} {{dshield.error}}
    </div>
    <div class="row"><a class="showmodal" href=#>click me for modal</a></div>
    <div class="row center">
        <ul class="unstyled">
        {{#each objKeyValue dshield.data}}

            {{#if isAnObject value}}
                <li><ul class="unstyled">{{key}}
                {{#with value}}
                    {{#each objKeyValue this}}
                        <li>{{key}}:
                        {{value}}</li>
                    {{/each}}
                {{/with}}
                </ul></li>
            {{else}}
                <li>
                    {{key}}:
                    {{value}}
                </li>
            {{/if}}
        {{/each}}
        </ul>
    </div>
    <div class="row center">
        <span>raw json:</span>
        <span class="unstyled">
                {{dshield.content}}
        </span>
    </div>
    {{>dshieldmodal}}
</div>
</body>
</template>

<template name="dshieldmodal">
    <div class="modal fade" id="modaldshieldwindow">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                   <button type="button" class="close" data-dismiss="modal">&times;</button>
                   <h4>DShield Results</h4>
                </div>
                <div class="modal-body">
                    <div class="row center">
                        <div class="well">
                            dshield: {{dshield.status}} {{dshield.error}}
                        </div>
                    </div>
                    <div class="row  center">
                        <ul class="list-unstyled">
                        {{#each objKeyValue dshield.data}}

                            {{#if isAnObject value}}
                                <li><ul class="list-unstyled">{{key}}
                                {{#with value}}
                                    {{#each objKeyValue this}}
                                        <li>{{key}}:
                                        {{value}}</li>
                                    {{/each}}
                                {{/with}}
                                </ul></li>
                            {{else}}
                                <li>
                                    {{key}}:
                                    {{value}}
                                </li>
                            {{/if}}
                        {{/each}}
                        </ul>
                    </div>
                    <div class="col-xs-1"><button class="btn btn-xs" data-toggle="collapse" data-target="#rawdshieldjson">raw json</button></div>
                    <div class="col-xs-7 col-xs-offset-1">
                        <div id='rawdshieldjson' class="collapse">
                            <pre>{{dshield.content}}</pre>
                        </div>
                    </div>
              </div>
              <div class="modal-footer">
                <a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
              </div>
            </div>
        </div>
    </div>
</template>
